﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HRM.Model
{
    public class SearchDepartmentService : IDepartmentService
    {
        public List<PhongBan> SearchBy(int mode, object input)
        {
            using (HRMEntities entities = new HRMEntities())
            {
                if (mode == 1)
                {
                    var inp = Convert.ToInt32(input);
                    return entities.PhongBans.Where(x => x.MaPhongBan == inp).ToList();
                }
                else
                {
                    string inpu = (string)input;
                    if (mode == 2) return entities.PhongBans.Where(x => x.TenPhongBan.Contains(inpu)).ToList();
                    else if (mode == 3) return entities.PhongBans.Where(x => x.DiaChi.Contains(inpu)).ToList();
                    else if (mode == 3) return entities.PhongBans.Where(x => x.SDT.Contains(inpu)).ToList();
                }
            }
            return new List<PhongBan>();
        }
    }
}
